package day01.日期类.Acm;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

/**
 * @author feng
 * @Date 2022/1/4 9:57
 * 计算2个日期"2012-3-17"到"2012-4-6"中间有多少天？
 */
public class Test7 {
    public static void main(String[] args) throws ParseException {
        String s1 = "2012-3-17";
        String s2 = "2012-4-6";

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = dateFormat.parse(s1);
        Date date2 = dateFormat.parse(s2);
        long time1 = date1.getTime();
        long time2 = date2.getTime();

        long time = time2 - time1;
        long day = time / 1000 / 60 / 60 / 24;
        System.out.println("总天数" + day);

    }
}
